package com.jiawa.wiki.controller;

import com.jiawa.wiki.domain.Test;
import com.jiawa.wiki.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class TestController {
    @Autowired
    private TestService testService;

    @Value("${test.hello:TEST}")
    private String testHello;

    @RequestMapping(value = "/hello",method = RequestMethod.GET)
    public String hello(){
        return "Hello World"+testHello;
    }

    @PostMapping(value = "/hello/post")
    public String hellopost(String name){
        return "Hello World! Post,"+name;
    }

    @RequestMapping( "/test/list")
    public List<Test> list(String name){
        return testService.findAll();
    }
}
